Roll icon definitions into themes (Theme.icons)#370
Open
CarlosNZ wants to merge 11 commits into
Open
Conversation
Bundle size impact
|
| Format | Base raw | PR raw | Δ raw | Base gzip | PR gzip | Δ gzip |
|---|---|---|---|---|---|---|
| esm | 56.88 KB | 56.55 KB | 🟢 -334 B (-0.57%) | 20.29 KB | 20.23 KB | 🟢 -65 B (-0.31%) |
| cjs | 58.39 KB | 58.01 KB | 🟢 -381 B (-0.64%) | 20.35 KB | 20.27 KB | 🟢 -87 B (-0.42%) |
@json-edit-react/themes
| Format | Base raw | PR raw | Δ raw | Base gzip | PR gzip | Δ gzip |
|---|---|---|---|---|---|---|
| esm | 5.98 KB | 5.98 KB | ⚪ no change | 1.69 KB | 1.69 KB | ⚪ no change |
| cjs | 5.99 KB | 5.99 KB | ⚪ no change | 1.65 KB | 1.65 KB | ⚪ no change |
@json-edit-react/utils
| Format | Base raw | PR raw | Δ raw | Base gzip | PR gzip | Δ gzip |
|---|---|---|---|---|---|---|
| esm | 3.37 KB | 4.62 KB | 🔺 +1.25 KB (+37.11%) | 1.49 KB | 2.09 KB | 🔺 +619 B (+40.62%) |
| cjs | 3.46 KB | 4.70 KB | 🔺 +1.24 KB (+35.86%) | 1.47 KB | 2.09 KB | 🔺 +627 B (+41.52%) |
Measured from build/index.{cjs,esm}.js. Gzip at level 9.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #369.
Themes now own their icon glyphs, not just their colours. The standalone
iconsprop is removed; a theme supplies glyphs viaTheme.icons(keyedadd/edit/delete/copy/ok/cancel/collection), each anIconDefinition(contentplus optionalviewBox/svgProps/scale). User-supplied glyphs are themeable throughcurrentColorexactly like the built-ins, and per-instance overrides compose through the samethemelayering as style overrides — one mechanism instead of two.Core (
json-edit-react)IconDefinition/ThemeIconstypes;Themegainsicons?.IconReplacementsandJsonEditorProps.iconsremoved.IconDefinitions ondefaultTheme.icons(each carrying itsscalecorrection);defaultTheme.ts→.tsx.mergeIconscomposesiconsacross the theme array (defaultThemeas layer 0), so the merged set is always complete — the renderer drops its per-nameswitch/fallback and derives the paint key by the naming invariant (icon+ PascalCase).IconAdd…IconChevroncomponents +IconPropsare gone (their markup now lives indefaultTheme.icons).IconSvgis exported as the glyph renderer — pass anIconDefinition's parts; it owns the size baseline so the ratio constant stays internal.chevronglyph key is renamedcollection; the collapse chevron stays hover-inert (nojer-icon).@json-edit-react/utilsiconFromSvg(svg): builds anIconDefinitionfrom a raw SVG string (full<svg>…</svg>or bare inner markup), a React<svg>element (unwrapped via its props/children), or an existingIconDefinition(passthrough). String inputs are interned for inline referential stability — reuses a generalisedinternpromoted to a shared module (filters behaviour unchanged).@json-edit-react/themesicons:react/react/jsx-runtimeare kept external (never bundled), andreactis declared an optional peer dep. No current theme ships glyphs yet.Demo
IconDefinitionas the actual themed glyph via the exportedIconSvg(display-only) instead of the raw React-element internals.Docs
Theme.icons/IconDefinition/ thecurrentColorrule /scale; drops theiconsprop row; updates the exports list.iconsprop →theme.icons,JSX.Element→IconDefinition/iconFromSvg,chevron→collection, and the removed exports.Breaking changes
iconsprop removed → usetheme.icons.IconAdd…IconChevron,IconProps,IconReplacementsno longer exported.chevronicon key →collection.Testing
test/icons.test.tsx(core) andpackages/utils/test/icon.test.tsx. Full suites green (643 core tests), lint clean, demo typechecks.🤖 Generated with Claude Code